<template>
	<view class="beijingse">
		<view class="mainpadding ffffff">
			<view class="flexbetween">
				<view class="">
					<view class="flexleft">
						<view class="sanshier xiaohei fonweight">保证金：</view>
						<u-icon name="info-circle-fill" color="#999999" size="20" @click="bshow=true"></u-icon>
					</view>
					<view class="xiaohong fonweight margin_top2" style="font-size: 64rpx;">￥{{bzj_price}}
					</view>
				</view>
				<image style="width: 124.03rpx;height: 137.81rpx;" src="../static/image/system/qs.png" mode=""></image>
			</view>
		</view>
		<view class="mainpadding ffffff margin_top2">
			<view class="sanshier xiaohei fonweight">竞拍说明</view>
			<view class="ershil xiaohei margin_top2">
				<u-parse :content="jpsm"></u-parse>
			</view>
		</view>
		<view class="gudingdb ffffff mainpadding flexbetween">
			<view class="titletext xiaohei">保证金：
				<text class="titletext xiaohong fonweight">￥{{bzj_price}}</text>
			</view>
			<view class="xhbtn flexcenter" @click="payinfo()">交保证金</view>
		</view>
		<!-- 保证金规则 -->
		<u-popup :show="bshow" @close="bshow=false" :round="10" mode="center">
			<view class="mainpadding">
				<view class="sanshier fonweight textcenter xiaohei">保证金规则</view>
				<view class="" style="height: 500rpx; overflow: auto; width: 550rpx;">
					<view class="xiaohei ershiba margin_top">
						<u-parse :content="bzjgz"></u-parse>
					</view>
				</view>
				<view class="bigbtn margin_top5" @click="bshow=false">关闭</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				userInfo: {},
				openId: "",
				jpsm: "",
				bzjgz: "",
				bshow: false,
				bzj_price: "",
			}
		},
		onLoad(options) {
			this.bzj_price = options.price
		},
		onShow() {
			// 获取openid
			// this.getopenid()
			this.getinfo()
			this.getsystem()
		},
		methods: {
			getopenid() {
				let that = this
				uni.login({
					success(res) {
						if (res.code) {
							httpRequest.request('/api/user/getopenid', 'GET', {
								code: res.code
							}).then(resp => {
								that.openId = resp.data.openid
							})
						}
					}
				})
			},
			payinfo() {
				if (this.userInfo.smrz == null || this.userInfo.smrz.status == 0) {
					httpRequest.toast("请先进行实名认证")
					setTimeout(() => {
						uni.redirectTo({
							url: "/pages_mypage/renzhengxx"
						})
					}, 1000)
					return false
				}
				if (this.userInfo.smrz.status == 1) {
					httpRequest.toast("实名认证审核中，暂时无法缴纳保证金")
					return false
				}
				if (this.userInfo.smrz.status == 3) {
					httpRequest.toast("实名认证已驳回请重新认证")
					setTimeout(() => {
						uni.redirectTo({
							url: "/pages_mypage/shenhejg"
						})
					}, 1000)
					return false
				}
				httpRequest.request('/api/Rechargecl/rechargeMoney', 'POST', {
					// openid: this.openId,
					price: this.bzj_price,
				}).then(res => {
					let data = JSON.parse(res.data.wxconfig)
					if (res.code == 1) {
						uni.requestPayment({
							provider: 'wxpay',
							timeStamp: data.timeStamp,
							nonceStr: data.nonceStr,
							package: data.package,
							signType: data.signType,
							paySign: data.paySign,
							success: function(res) {
								// 支付成功
								uni.navigateBack(1)
							},
							fail: function(err) {

							}
						});
					}
				})
			},
			getinfo() {
				uni.showLoading({
					mask: true,
					title: "请稍后"
				})
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					uni.hideLoading()
					if (res.code == 1) {
						this.userInfo = res.data
					} else {
						this.userInfo = null
					}
				})
			},
			getsystem() {
				httpRequest.request('/api/index/getConfigInfoItem', 'GET', {
					pidtype: "about_set",
					type: "jpsm",
				}).then(res => {
					this.jpsm = res.data
				})
				httpRequest.request('/api/index/getConfigInfoItem', 'GET', {
					pidtype: "about_set",
					type: "bzjgz",
				}).then(res => {
					this.bzjgz = res.data
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.xhbtn {
		font-weight: 700;
		font-size: 30rpx;
		color: #FFFFFF;
		width: 260rpx;
		height: 100rpx;
		background: #BA9549;
	}
</style>